package com.ft.oa.web.dev;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ft.oa.domain.dev.DevTask;
import com.ft.oa.domain.dev.DevTaskItem;
import com.ft.oa.domain.dev.dto.DevAttachmentDto;
import com.ft.oa.domain.development.DevAllocateStaff;
import com.ft.oa.domain.dto.ApiResult;
import com.ft.oa.service.dev.DevTaskItemService;
import com.ft.oa.service.dev.DevTaskService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * 研发任务
 */

@RestController
@RequestMapping("/devTask")
public class DevTaskController {

    @Resource
    private DevTaskService devTaskService;

    @Resource
    private DevTaskItemService devTaskItemService;
    /**
     * 新增
     */
    @PostMapping("/add")
    public ApiResult add(@RequestBody DevTask devTask){
        ApiResult result = devTaskService.add(devTask);
        return result;
    }

    /**
     * 新增任务进展
     * @param devTaskItem
     * @return
     */
    @PostMapping("/addItem")
    public ApiResult addDevTaskItem(@RequestBody DevTaskItem devTaskItem){
        ApiResult result = devTaskItemService.add(devTaskItem);
        return result;
    }

    /**
     * 分页
     */
    @PostMapping  ("/page")
    public ApiResult page(@RequestBody DevTask devTask){
        Page<DevTask> page = devTaskService.page(devTask);
        return ApiResult.successWithData(page);
    }

    /**
     * 查询研发项目参与人
     * @param devAllocateStaff
     * @return
     */
    @PostMapping("/queryDevAllocateStaff")
    public ApiResult queryDevAllocateStaff(@RequestBody DevAllocateStaff devAllocateStaff){
        ApiResult result = devTaskService.queryStaff(devAllocateStaff);
        return result;
    }

    /**
     * 查询项目任务详情
     * @param devTask
     * @return
     */
    @PostMapping("/view")
    public ApiResult view(@RequestBody DevTask devTask){
        ApiResult result = devTaskService.view(devTask);
        return result;
    }

    @PostMapping("/del")
    public ApiResult del(@RequestBody DevTask devTask){
        ApiResult result = devTaskService.del(devTask);
        return result;
    }

    @PostMapping("/queryDevAllocate")
    public ApiResult queryDevAllocate(){
        ApiResult result = devTaskService.queryDevAllocate();
        return result;
    }

    /**
     * 保存附件信息
     * @param devAttachmentDto
     * @return
     */
    @PostMapping("/saveAttachment")
    public ApiResult saveAttachment(@RequestBody DevAttachmentDto devAttachmentDto){
        ApiResult result = devTaskService.saveAttachment(devAttachmentDto);
        return result;
    }

}
